#!/usr/bin/perl
# file:write_ten.pl
use strict;
open (PIPE, "| ./read_three.pl") or die "Cannot open pipe: $!";
select PIPE; $| = 1; select STDOUT;
my $count = 0;
for (1..10){
    warn "waiting line $_\n";
    print PIPE "This is line number $_\n" and $count++;
    sleep 1;
}
close PIPE or die "Cannot close pipe: $!";
print "Wrote $count lines of text\n/";